package com.ruoyi.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.demo.domain.roomUsage;
import com.ruoyi.demo.domain.vo.roomSelectVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoomUsageMapper extends BaseMapper<roomUsage> {
    @Select("select count(*) from room where is_deleted=0")
    int getRoomSum();

    @Select("SELECT count(*) FROM meet WHERE DATE(created_at) = CURDATE() " +
            "AND (status = 0 OR status = 1 OR status = 2 OR status = 3)")
    int getTodayReserveCount();

    @Select("SELECT ROUND((COUNT(CASE WHEN status = 0 THEN 1 END) * 100.0 / NULLIF(COUNT(*), 0)), 2) AS usage_rate " +
            "FROM room;")
    String getRoomUsageRate();

    @Select("SELECT COUNT(*) FROM meet WHERE DATE_FORMAT(created_at, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')" +
            " AND (status = 0 OR status = 1 OR status = 2 OR status = 3)")
    int getThisMonthReserveSum();

    @Select("Select room_id,room_address from room where is_deleted=0 and `status`!=2")
    List<roomSelectVo> getRoomList();
}
//1